from settings import BOARD_SETTINGS
import pygame

class Tile(object):
    size=BOARD_SETTINGS.GRID_SIZE
    
    def __init__(self):
        self.playableTiles = [BlankTile]
    
    def onPlacement(self, x, y):
        self.location = (x,y)
        return self
    
    def onRemoval(self):
        pass
    
    def showTile(self):
        #returns a Surface that shows the tile
        srf = pygame.Surface((BOARD_SETTINGS.GRID_SIZE[0],BOARD_SETTINGS.GRID_SIZE[1]))
        srf.set_colorkey((0,0,0))
        return srf
    
    def canBePlayedOn(self, tile):
    #Returns True if the tile can be played on the type of arg tile
        for x in self.playableTiles:
            if isinstance(tile, x):
                print "%s can be played on %s"%(self, x)
                return True
        return False

class BlankTile(Tile):
    def __init__(self):
        super(BlankTile, self).__init__()

class VisibleTile(BlankTile):
    def __init__(self):
        super(VisibleTile, self).__init__()
        self.playableTiles.append(VisibleTile)
        self.playableTiles.append(InvisibleTile)

class InvisibleTile(Tile):
    def __init__(self):
        super(InvisibleTile, self).__init__()
    
    def showTile(self):
        srf = super(InvisibleTile, self).showTile()
        srf.set_alpha(200)
        color = pygame.Color(53,53,53,255)
        srf.fill(color)
        return srf